package com.anttech.shoedemo;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import java.util.HashMap;
import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * Created by chenshen on 16/10/20.
 */

public class SelectModeListAdapter extends BaseAdapter {
    private String[] weekArray;
    private Context mContext;
    public HashMap<String,Integer> seleclDayMap;

    public SelectModeListAdapter(Context mContext) {
        weekArray = mContext.getResources().getStringArray(R.array.mode_array);
        this.mContext = mContext;
        this.seleclDayMap = new HashMap<>();

    }

    public SelectModeListAdapter(Context mContext, int defalutSelect) {
        weekArray = mContext.getResources().getStringArray(R.array.mode_array);
        this.mContext = mContext;
        this.seleclDayMap = new HashMap<>();
        this.seleclDayMap.put(weekArray[defalutSelect],defalutSelect);

    }

    @Override
    public int getCount() {
        return weekArray.length;
    }

    @Override
    public Object getItem(int position) {
        return position;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder = null;
        if (convertView == null) {
            convertView = LayoutInflater.from(parent.getContext()).inflate(R.layout.select_weekday_item, null);
            viewHolder = new ViewHolder(convertView);
            convertView.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }
        final  String dayKey = weekArray[position];
        viewHolder.weekDay.setText(dayKey);
        return convertView;
    }

    static class ViewHolder {
        @Bind(R.id.week_day)
        TextView weekDay;
        @Bind(R.id.select_icon)
        ImageView selectIcon;

        ViewHolder(View view) {
            ButterKnife.bind(this, view);
        }
    }

}
